//
//  BuyHeader.m
//  体育商城
//
//  Created by  on 2022/9/23.
//

#import "BuyHeader.h"
@interface BuyHeader()
@property (strong, nonatomic) IBOutlet UIImageView *img;
@property (strong, nonatomic) IBOutlet UILabel *tips;
@property (strong, nonatomic) IBOutlet UILabel *money;
@property (strong, nonatomic) IBOutlet UILabel *name;
@property (strong, nonatomic) NSURLSessionTask *task;
@end
@implementation BuyHeader
- (void)setModel:(Goods *)model{
    if (_model != model) {
        if (self.task) {
            [self.task cancel];
        }
        self.img.image = nil;
        self.name.text = model.brandName;
        self.money.text = [NSString stringWithFormat:LS(@"¥:%@"),model.price];
        self.tips.text = [NSString stringWithFormat:LS(@"月销量%d万+"),[model.productReference intValue] / 10000];
        self.task = [UIImage imageWithURL:model.mainImage block:^(UIImage * _Nonnull image) {
            self.img.image = image;
        }];
    }
}
@end
